package com.study;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.study.util.FileUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Test9
 *
 * @author wanghuilong
 * @version 1.0
 * @description
 * @date 2022/12/9 16:25
 */
public class Test9 {

    public static void main(String[] args) {
        List<String> contents = FileUtil.readTxtFileIntoStringArrList("/Users/wanghuilong/IdeaProjects/lazy/src/main/resources/file/1.txt",null);

        Map<String,List<String>> map = new HashMap<>();

        for (String contentsStr : contents) {
            String[] split = contentsStr.trim().split(":");
            String methonName = split[0].replace("hx-mall-service.","");
            List<String> strings = map.get(methonName);
            if(strings == null){
                strings = new ArrayList<>();
                map.put(methonName,strings);
            }
            strings.add(split[2]);
        }

        System.out.println(JSONObject.toJSONString(map));

//        JSONObject jsonObject = JSONObject.parseObject(content);
//        JSONArray hitsJsonArray = jsonObject.getJSONObject("hits").getJSONArray("hits");
//
//        List<String> product_unit_codes = new ArrayList<>();
//        for (int i = 0; i < hitsJsonArray.size(); i++) {
//            JSONObject hitsJsonArrayJSONObject = hitsJsonArray.getJSONObject(i);
//            String product_unit_code = hitsJsonArrayJSONObject.getJSONObject("_source").getString("product_unit_code");
//            product_unit_codes.add(product_unit_code);
//        }
//
//        System.out.println(JSONObject.toJSONString(product_unit_codes));




    }

}
